package view.WelcomePanels.SubPanels;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import view.HelperClasses.ImageButton;
import view.WelcomeFrame;

/**
 *
 * @author Joachim
 */
public class BackButtonPanel extends JPanel {
    
    private WelcomeFrame frame;
    
    public BackButtonPanel(WelcomeFrame frame) {
        this.frame = frame;
        initPanel();
        addComponents();
    }
    
    private void initPanel() {
        this.setOpaque(false);
        this.setPreferredSize(new Dimension(75,50));
        this.setLayout(new FlowLayout(FlowLayout.LEADING,0,0));
    }
    
    private void addComponents() {
        JButton btnBack = new ImageButton(getClass().getResource("/resources/back.png"));
        btnBack.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                frame.showCard("LOGIN");
            }
        });
        this.add(btnBack);
    }
    
}
